﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace OCR
{
    public partial class InputConfigName : Form
    {
        private List<CardType> configs;
        private string configName;
        public string ConfigName
        {
            get { return this.configName; }
            set { this.configName = value; }
        }
        public InputConfigName(List<CardType> configs,string configDefaultName)
        {
            InitializeComponent();
            this.configs = configs;
            this.configName = configDefaultName;
            this.tbName.Text = configDefaultName;
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.tbName.Text.Trim()))
            {
                MessageBox.Show("名称不能为空!");
                return;
            }
            if (this.configs.Find(d => d.Name == this.tbName.Text.Trim()) != null)
            {
                MessageBox.Show("方案名称重复!");
                return;
            }
            else
            {
                this.configName = this.tbName.Text.Trim();
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }
    }
}
